package com.Dialogs;


import android.app.AlertDialog;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ListView;
import android.widget.TextView;
import com.Adapters.PictureListAdapter;
import com.Adapters.Items.ItemAlbum;
import com.Adapters.Items.ItemProfile;
import com.shareup.R;


public class DialogAlbum extends AlertDialog {

    private String ITEM_DELETE;

    private String ITEM_INFO;

    private ItemAlbum albumSetting;

    private final ListView itemlist;

    private final OnItemClickListener OnOption = new OnItemClickListener() {

        @Override
        public void onItemClick(AdapterView<?> arg0, View v, int position, long arg3) {

            String menu = ((TextView) v.findViewById(R.id.text_comment)).getText().toString();

            if (menu.equals(ITEM_DELETE))
                albumSetting.delete();

            else
                if (menu.equals(ITEM_INFO))
                    albumSetting.showInfo();

            dismiss();
        }
    };

    private final View view;

    public DialogAlbum(Context context, ItemAlbum album) {

        super(context);
        this.albumSetting = album;

        LayoutInflater inflater = (LayoutInflater) getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        view = inflater.inflate(R.layout.dialog_action_list, null);
        //
        itemlist = (ListView) view.findViewById(R.id.item_list);
        //
        //
        this.setView(view);
        //
        String[] list = context.getResources().getStringArray(R.array.album);
        PictureListAdapter adapter = new PictureListAdapter(context, R.layout.option_picture_text, R.id.text_comment);
        //
        ITEM_INFO = list[0];
        ITEM_DELETE = list[1];
        adapter.add(new ItemProfile(ITEM_INFO, R.drawable.information_normal, 0, false));
        adapter.add(new ItemProfile(ITEM_DELETE, R.drawable.delete_normal, 0, false));

        //
        itemlist.setAdapter(adapter);
        itemlist.setOnItemClickListener(OnOption);
    }

    @Override
    public void setTitle(CharSequence title) {

    }
}
